import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('CheckboxDemo'),
        leading: const Icon(Icons.menu),
        centerTitle: true,
        actions: const [
          Icon(Icons.settings),
        ],
      ),
      body: CheckboxDemo(),
    );
  }
}

class CheckboxDemo extends StatefulWidget {
  const CheckboxDemo({super.key});

  @override
  State<CheckboxDemo> createState() => _CheckboxDemoState();
}

class _CheckboxDemoState extends State<CheckboxDemo> {
  bool _male = true;
  bool _female = false;
  bool _transgender = true;
  bool _value1 = true;
  bool _value2 = false;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ListTile(
          leading: Checkbox(
            value: this._male,
            onChanged: (bool? value) {
              setState(() => _male = value ?? false);
            },
          ),
          title: Text('男'),
        ),
        ListTile(
          leading: Checkbox(
            value: this._female,
            onChanged: (bool? value) {
              setState(() => _female = value ?? false);
            },
          ),
          title: Text('女'),
        ),
        ListTile(
          leading: Checkbox(
            value: this._transgender,
            onChanged: (bool? value) {
              setState(() => _transgender = value ?? false);
            },
            activeColor: Colors.pink,
            checkColor: Colors.yellow,
          ),
          title: Text('人妖'),
        ),
        CheckboxListTile(
          secondary: Icon(Icons.settings, size: 50,),
          value: this._value1,
          onChanged: (bool? value) {
            setState(() {
              this._value1 = value ?? false;
            });
          },
          title: Text('1:00 叫我起床'),
          subtitle: Text('太困了起不来'),
          activeColor: Colors.green,
          checkColor: Colors.green,
          selected: this._value1,
        ),
        CheckboxListTile(
          secondary: Icon(Icons.settings, size: 50,),
          value: this._value2,
          onChanged: (bool? value) {
            setState(() {
              this._value2 = value ?? false;
            });
          },
          title: Text('3:00 叫我起床'),
          subtitle: Text('行'),
        )
      ],
    );
  }
}